package com.stackoverflow

import org.codehaus.groovy.grails.validation.MinSizeConstraint;

abstract class Postagem {

	String texto

	Date dataCriacao

	Date dataEdicao

	static belongsTo = [usuario: Usuario]

	static hasMany = [votos: Voto]

	static constraints = {
		texto nullable: false, minSize: 5
		dataCriacao nullable: true
		dataEdicao nullable: true
	}

	static mapping = {
		tablePerHierarchy false
		texto type: "text"
	}

	def beforeInsert(){
		dataCriacao = new Date()
	}

	def beforeUpdate(){
		dataEdicao = new Date()
	}
}
